package com.fausto.learnimprint.common.lang

sealed class Option<T>{
    class Some<T>(val content: T): Option<T>()
    class None<T>: Option<T>()

    fun unwrap(): T{
        return expect(EmptyContentException())
    }

    fun expect(err: Exception): T{
        return when(this){
            is None -> throw err
            is Some -> this.content
        }
    }
}

class EmptyContentException(msg: String = "空内容未检异常!"): RuntimeException(msg)
